﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login2ajax.aspx.cs" Inherits="Login2ajax" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>登录</title>
    <link href="css/1.css" rel="stylesheet" type="text/css" />
    <link href="css/2.css" rel="stylesheet" type="text/css" />
    <link href="css/validator.css" rel="stylesheet" type="text/css" />

    <script src="js/jquery.js" type="text/javascript" language="javascript"></script>

    <script src="js/formValidator.js" type="text/javascript" language="javascript"></script>

    <script type="text/javascript" src="tipWinodw/tipswindown.js"></script>

    <script language="javascript" type="text/javascript">
$(document).ready(function(){ 
 $("#btnLogin").click(function(){
        var flag = jQuery.formValidator.PageIsValid('1');
        if(flag){
            $.ajax({
        url: 'MyHandder/LoginHandler.ashx?UserName='+$("#txtUserName").val()+"&UserPass="+$("#txtUserPass").val()+"&CheckCode="+$("#txtCheckCode").val(),
        type: 'POST',
        dataType: 'html',
        timeout: 5000,
        error: function(){
            alert("服务器错误！");
        },
        success: function(xml){
            switch(xml){
              case "1":
                  childCloseWindown();
                  parent.location.reload()
              break;
              case "-1":
                  alert("验证码输入错误");
              break;
              case "-2":
                  alert("登录信息不能为空");
                     break;
             case "-3":
                 alert("账户异常,或未被审核");
                 break;     
             case "-4":
                 alert("登录未被审核！");
                 break;     
                }
              $("#code").attr("src",'admin/Codeimg.aspx?'+Math.random());
            }
    });
        }
     });
$.formValidator.initConfig({onError:function(msg){alert(msg)}});
     $("#txtUserName").formValidator({onshow:"请输入用户名",onfocus:"不能为空",oncorrect:"合法"}).InputValidator({min:1,onerror:"用户名输入错误"});
     $("#txtUserPass").formValidator({onshow:"请输入登录密码",onfocus:"不能为空",oncorrect:"合法"}).InputValidator({min:1,onerror:"登录密码输入错误"});
     $("#txtCheckCode").formValidator({onshow:"请输入验证码",onfocus:"不能为空",oncorrect:"合法"}).InputValidator({min:4,max:4,onerror:"验证码输入错误"});
   
});
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div class="zc">
        <div class="zc1">
            会员登录</div>
        <div class="zc2">
            <p>
                <table>
                    <td>
                        <span class="zl2">用户名：</span>
                    </td>
                    <td>
                        <input type="text" runat="server" id="txtUserName" class="bb" />
                    </td>
                    <td>
                        <div id="txtUserNameTip" style="width: 250px; display: inline;">
                        </div>
                    </td>
                </table>
            </p>
            <p>
                <table>
                    <td>
                        <span class="zl2">密 码：</span>
                    </td>
                    <td>
                        <input type="password" runat="server" id="txtUserPass" class="bb" />
                    </td>
                    <td>
                        <div id="txtUserPassTip" style="width: 250px; display: inline;">
                        </div>
                    </td>
                </table>
            </p>
            <p>
                <table>
                    <td>
                        <span class="zl2">验证码：</span>
                    </td>
                    <td>
                        <input id="txtCheckCode" runat="server" type="text" class="bb" />
                        <em>
                            <img id="code" style="cursor: pointer" onclick="this.src='admin/Codeimg.aspx?'+Math.random();"
                                src="admin/Codeimg.aspx" align="middle" alt="换一张" /></em>
                    </td>
                    <td>
                        <div id="txtCheckCodeTip">
                        </div>
                    </td>
                </table>
            </p>
            <p>
                <a href="Regster.aspx" class="tijiao3"><span style="color: White">&nbsp;立即注册&nbsp;</span></a>
                <input type="button" id="btnLogin" value="登录" class="tijiao3" />
                <span onclick="javascript:childCloseWindown();">父窗口</span>
            </p>
        </div>
    </div>
    </form>
</body>
</html>
